package com.espirit.builder.biz;

import com.espirit.eap.manager.ModelBuilderSupport;
import com.espirit.eap.pagelayout.Element;
import com.espirit.eap.pagelayout.ModelField;

//@Component
public class AcctItemFactorBuilderSupport extends ModelBuilderSupport {
	protected static final String NAME = "name";
	protected static final String PROPERTY = "property";
	protected static final String FACTOR = "factor";
	protected static final String REMARK = "remark";
	
	
	@Override
	public boolean init() {
		return true;
	}

	@Override
	public void buildFields() {
		super.buildFields();
		addModelField(NAME, "Name", "名称");
		addModelField(PROPERTY, "Property", "属性");
		addModelField(FACTOR, "Factor", "计算因子");
		addModelField(REMARK, "Remark", "备注");
	}
	
	@Override
	protected void addSearchFields() {
		super.addSearchField(convertPropertyToField(NAME));
	}
	
	@Override
	protected void addListFields() {
		addListField(convertPropertyToField(NAME, PROPERTY, FACTOR, REMARK));
	}
	
	@Override
	protected void addDetailFields() {
		addDetailField(convertPropertyToField(NAME, PROPERTY, FACTOR, REMARK));
	}
	
	
	@Override
	protected Element convertFieldToElement(ModelField mf, boolean isListLayout) {
		Element element = super.convertFieldToElement(mf, isListLayout);
		String name = element.getName();
//		if (!isListLayout){
			
			if (FACTOR.equals(name) ){
				if (!isListLayout){
					element.setTagName("textarea");
				}
			}
//		}
		return element;
	}
	
	@Override
	protected void gatherExproperties() {
		exProperties.put(REQUIRED, new String[]{NAME});
	}
}
